/*  
 * @(#) Constants.java Create on 2014-03-13 下午04:03:30   
 *   
 * Copyright 2014 by fibrlink.   
 */

package com.springdemo.module.systemmanager.controller;

import com.springdemo.module.systemmanager.entity.MenuPage;
import com.springdemo.module.systemmanager.entity.myentity.MyMenu;
import com.springdemo.module.systemmanager.service.MenuService;
import com.springdemo.tools.NumberHelper;
import com.springdemo.tools.jackjson.JackJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author qiaowan
 * @date 2014-03-13
 */
@Controller
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private MenuService<MenuPage> menuService;

    /**
     * 获取左侧菜单
     *
     * @throws Exception
     * @Title: findAllFunctionList
     * @data:2014-3-18上午10:13:33
     * @author:qiaowan
     */
    @RequestMapping(value = "/findAllFunctionList", method = RequestMethod.GET)
    @ResponseBody
    public String  findAllFunctionList() throws Exception {
        //String id=BaseAction.getCurrentUser().getId();
        List<MyMenu> parentList = menuService.findAllFunctionList("84523cfd32464d5ab252decdf43f932d");
       return JackJson.fromObjectToJson(parentList);
    }

    /**
     * 获取所有的菜单信息
     *
     * @throws Exception
     * @Title: findAllModuleList
     * @data:2014-4-9下午06:48:58
     * @author:qiaowan
     */
    @RequestMapping(value = "/findAllMOdeuleList", method = RequestMethod.POST)
    public String findAllModuleList() throws Exception {
        return JackJson.fromObjectToJson(menuService.findAllModuleList());
    }

    /**
     * 异步获取菜单列表
     *
     * @throws Exception
     * @Title: getmenuList
     * @data:2014-3-14下午01:47:23
     * @author:qiaowan
     */
    public void getmenuList() throws Exception {
        //CommonSendMeg.writeMsg(JackJson.fromObjectToJson(menuService.getmenuList(null)));
    }

    /**
     * 跳转到列表页面
     *
     * @return
     * @Title: toMenulist
     * @data:2014-3-13下午04:18:23
     * @author:qiaowan
     */
    public String toMenulist() {
        return "menulist";
    }


    /**
     * 菜单列表查询
     *
     * @throws Exception
     * @Title: list
     * @data: 2014-03-13 下午04:03:30
     * @author: qiaowan
     */
    /*public void list() throws Exception {
        List<MenuPage> dataList = menuService.queryByList(getModel());
        //设置页面数据
        Map<String, Object> jsonMap = new HashMap<String, Object>();
        jsonMap.put("total", getModel().getPager().getRowCount());
        jsonMap.put("rows", dataList);
        CommonSendMeg.writeMsg(JackJson.fromObjectToJson(jsonMap));
    }
*/


    /**
     * 获取菜单图标
     *
     * @throws Exception
     * @Title: getMenuIcon
     * @data:2014-5-4下午03:32:44
     * @author:san
     */
    public void getMenuIcon( @RequestParam("flag") String flags ) throws Exception {
        //接受参数，是菜单，还是页面
        int flag = NumberHelper.stringToInt(flags);
        // CommonSendMeg.writeMsg(JackJson.fromObjectToJson(menuService.getMenuIcon(flag)));
    }

    /**
     * 得到菜单列表（combotree）
     *
     * @return
     * @throws Exception
     * @Title: queryMenuListBySyn
     * @data:2014-5-7上午10:46:38
     * @author:qiaowan
     */
    @RequestMapping("queryMenuListBySyn")
    public void queryMenuListBySyn() throws Exception {
        // CommonSendMeg.writeMsg(JackJson.fromObjectToJson(menuService.queryMenuListBySyn()));
    }


}
